import { FormSchema } from '/@/components/Form';
import { getMetrics } from '/@/api/monitor/metric';
import { getAlarmLvs } from '/@/api/monitor/rule';

export const schemas: FormSchema[] = [
  {
    field: 'nickname',
    component: 'Input',
    label: '规则名称',
    colProps: {
      span: 24,
    },
    required: true,
  },
  {
    field: 'metric',
    component: 'ApiSelect',
    label: '聚合指标',
    colProps: {
      span: 24,
    },
    defaultValue: 1,
    componentProps: {
      api: getMetrics,
      labelField: 'name',
      valueField: 'id',
    },
    required: true,
  },
  {
    field: 'max_alarm',
    component: 'Input',
    defaultValue: '0',
    label: '阈值上界',
    colProps: {
      span: 24,
    },
    required: true,
  },
  {
    field: 'min_alarm',
    component: 'Input',
    defaultValue: '0',
    label: '阈值下届',
    colProps: {
      span: 24,
    },
    required: true,
  },
  {
    field: 'alarm_level',
    component: 'ApiSelect',
    defaultValue: '1',
    label: '告警级别',
    colProps: {
      span: 24,
    },
    componentProps: {
      api: getAlarmLvs,
      labelField: 'value',
      valueField: 'value',
    },
    required: true,
  },
  {
    field: 'is_enable',
    component: 'RadioButtonGroup',
    defaultValue: 'false',
    label: '启用状态',
    colProps: {
      span: 24,
    },
    componentProps: {
      options: [
        { label: '启用', value: 'true' },
        { label: '停用', value: 'false' },
      ],
    },
    required: true,
  },
];
